package com.heima.feigns;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.WemediaFeignFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author mrchen
 * @date 2022/7/26 15:51
 */
// 声明feign客户端接口

@FeignClient(value = "leadnews-wemedia", //  要调用的是自媒体服务
                configuration = HeimaFeignAutoConfiguration.class, // feign接口的配置
                fallbackFactory = WemediaFeignFallback.class  // feign接口的服务降级类
)
public interface WemediaFeign {
    //               路径写全
    @GetMapping("/api/v1/user/findByName/{name}")
                     // 如果返回值有泛型，泛型不能省           // 参数注解变量名称要加
    public ResponseResult<WmUser> findByName(@PathVariable("name") String name);
    @PostMapping("/api/v1/user/save")
    public ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    @GetMapping("/api/v1/news/one/{id}")
    public ResponseResult<WmNews> findWmNewsById(@PathVariable("id") Integer id);
    @PutMapping("/api/v1/news/update")
    ResponseResult updateWmNews(@RequestBody WmNews wmNews);
}
